home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 050a.dms / 050a.adf / ASCII_READER.AMOS / ASCII_READER.amosSourceCode next >
AMOS Source Code  |  1992-02-26  |  5KB  |  223 lines

  1. '***************************************************************************** 
  2. '*                       Text File Dumper Routine V1                         *               
  3. '*                    Originally Written By Steve Bennett                    *         
  4. '*                Adapted for Absolute beginners guide to Amos               *           
  5. '***************************************************************************** 
  6. _SETUP_MENU
  7.  
  8. Screen Open 1,658,167,2,Hires : Screen Display 1,,103,,
  9. Curs Off : Flash Off : Colour 0,$0 : Colour 1,$FFF
  10. Cls 0 : Pen 1 : Paper 0 : Locate 0,1
  11. Screen To Front 0
  12. Global SH
  13. SH=1
  14. _BANKLOAD
  15.  
  16. Rem this is the main loop, checks for option selection then calls
  17. Rem relevant procedure.
  18. '------------------------
  19. Do 
  20.    Screen 0
  21.    
  22.    MZ=Mouse Zone : MK=Mouse Key
  23.    
  24.    If MZ=1 and MK=1 Then _BANKLOAD
  25.    If MZ=2 and MK=1 Then _NLINE
  26.    If MZ=3 and MK=1 Then _NPAGE
  27.    If MZ=4 and MK=1 Then _DUMP_FILE
  28.    If MZ=5 and MK=1 Then Edit 
  29.  
  30. Loop 
  31.  
  32. Procedure _NLINE
  33. 'shared means the following variables will be SHARED with the other procedures   
  34. '------------------------------------------------------------------------------
  35.    Shared BEGIN,POSITION,FINISH,CURRENT_LINE
  36.    
  37.    If Length(9)=0 Then Bell 1 : Pop Proc
  38.    
  39.    If POSITION=FINISH Then POSITION=0 : CURRENT_LINE=0 : _NPAGE
  40.    
  41.    Screen 1
  42.    
  43.    TEMP$=""
  44.    
  45.    While Asc(TMP$)<>10 and POSITION<>FINISH
  46.       
  47.       LETTER=Peek(BEGIN+POSITION)
  48.       TMP$=Chr$(LETTER)
  49.       
  50.       If Asc(TMP$)=10
  51.          Print 
  52.          Screen 0 : Inc CURRENT_LINE : Ink 1,12 : Text 470,51,"     " : Text 470,51,Str$(CURRENT_LINE) : Screen 1
  53.       Else 
  54.          TEMP$=TEMP$+TMP$
  55.       End If 
  56.       
  57.       If POSITION<>FINISH Then Inc POSITION
  58.       
  59.    Wend 
  60.    
  61.    Print TEMP$;
  62.    
  63. End Proc
  64. Procedure _NPAGE
  65.    
  66.    Shared BEGIN,POSITION,FINISH,CURRENT_LINE
  67.    
  68.    Repeat : Until Mouse Key=0
  69.    
  70.    If Length(9)=0 Then Bell 1 : Pop Proc
  71.    
  72.    If POSITION=FINISH Then POSITION=0 : CURRENT_LINE=0
  73.    
  74.    Screen 1
  75.    
  76.    Cls 0 : Home 
  77.    
  78.    TEMP$=""
  79.    
  80.    While Y Curs<>19 and POSITION<>FINISH
  81.       
  82.       LETTER=Peek(BEGIN+POSITION)
  83.       TMP$=Chr$(LETTER)
  84.       
  85.       If Asc(TMP$)=10
  86.          Print 
  87.          Inc CURRENT_LINE
  88.          Print TEMP$; : TEMP$=""
  89.       Else 
  90.          TEMP$=TEMP$+TMP$
  91.       End If 
  92.       
  93.       If POSITION<>FINISH Then Inc POSITION
  94.       
  95.    Wend 
  96.    
  97.    Screen 0 : Ink 1,12 : Text 470,51,"     " : Text 470,51,Str$(CURRENT_LINE) : Screen 1
  98.    
  99. End Proc
  100. Procedure _SETUP_MENU
  101.    
  102.    Unpack 15 To 0
  103.    
  104.    Reserve Zone 8
  105.    
  106.    For Z=1 To 8
  107.       
  108.       Read A,B,C,D
  109.       
  110.       Set Zone Z,A,B To C,D
  111.       
  112.    Next Z
  113.    
  114.    Data 112,22,190,36
  115.    Data 198,22,276,36
  116.    Data 282,22,360,36
  117.    Data 366,22,444,36
  118.    Data 450,22,530,36
  119.    Data 284,77,364,91
  120.    Data 370,77,448,91
  121.    Data 454,77,536,91
  122.    
  123. End Proc
  124. Procedure _DUMP_FILE
  125.    
  126.    Repeat : Until Mouse Key=0
  127.    
  128.    If Length(9)=0 Then Bell 1 : Pop Proc
  129.    
  130.    Ink 1,12
  131.    Text 130,69,"Please Ensure That The Printer Is Ready To Print"
  132.    Screen Display 0,,,,97
  133.    
  134.    Repeat : Until Mouse Zone>5 and Mouse Key=1
  135.    
  136.    If Mouse Zone=6 Then SET=-1
  137.    If Mouse Zone=8 Then Screen Display 0,,,,60 : Pop Proc
  138.    
  139.    Text 130,69,"                                                "
  140.    Text 230,69,"Printing Text File"
  141.    
  142.    For T=Start(9) To Start(9)+Length(9)-1
  143.       
  144.       LETTER=Peek(T)
  145.       TMP$=Chr$(LETTER)
  146.       
  147.       B=Peek(T-1) : B$=Chr$(B) : B=Asc(B$)
  148.       
  149.       If Asc(TMP$)=9 or Asc(TMP$)=10
  150.          If B<>10
  151.             Lprint 
  152.          End If 
  153.       Else 
  154.          Lprint TMP$;
  155.       End If 
  156.       
  157.    Next T
  158.    
  159.    Text 135,69,"                                                "
  160.    Text 230,69,"Printing Complete"
  161.    
  162.    Wait 100
  163.    
  164.    Screen Display 0,,,,60
  165.    
  166. End Proc
  167. Procedure _BANKLOAD
  168.    
  169.    Shared BEGIN,FINISH,POSITION,CURRENT_LINE
  170.    
  171.    Screen Hide 0 : Screen Hide 1
  172.    
  173.    Clear Key 
  174. Dir$="df0:texts/"
  175. If SH=1 Then NAME$="df0:texts/0_help.txt" : SH=0 : Goto HC
  176.    NAME$=Fsel$("*.*","","Select .TXT Text File To Load !","")
  177.    If NAME$<>""
  178. HC:
  179.       Open In 1,NAME$
  180.       L=Lof(1)
  181.       Close 1
  182.       Erase 9
  183.       Reserve As Work 9,L
  184.       Bload NAME$,9
  185.       BEGIN=Start(9)
  186.       FINISH=Length(9)
  187.       POSITION=0
  188.       CURRENT_LINE=0
  189.       Screen Show 0 : Screen Show 1
  190.       _FIND_FILE_LENGTH
  191.       _NPAGE
  192.    End If 
  193.    
  194.    Screen Show 0 : Screen Show 1
  195.    
  196.    
  197. End Proc
  198. Procedure _FIND_FILE_LENGTH
  199.    
  200.    NUMBER_OF_LINES=0
  201.    
  202.    Screen 0
  203.    Ink 1,12
  204.    Text 298,51,"     "
  205.    Text 470,51,"     "
  206.    
  207.    Screen 1 : Cls 0 : Locate 0,1 : Centre "Counting Total Number Of Lines In File"
  208.    
  209.    For T=Start(9) To Start(9)+Length(9)
  210.       
  211.       P=Peek(T)
  212.       A$=Chr$(P)
  213.       
  214.       If Asc(A$)=10 Then Inc NUMBER_OF_LINES
  215.       
  216.    Next T
  217.    
  218.    Screen 0
  219.    Ink 1,12
  220.    Text 298,51,"     "
  221.    Text 298,51,Str$(NUMBER_OF_LINES)
  222.    
  223. End Proc